<?php
/**
 * More & Original PHP Framwork
 * Copyright (c) 2009 - 2010 IsMole Inc.
 * document ConfMaker 配置生成模块
 * $Id: ConfMaker_demo.php starten $
 */
class Control_ExcelConfMaker_createGmAward {
	var $theConf 	= array();
	var $fileName 	= 'tools.xls';
	var $tpl 		= ''; // 生成配置文件的模板
	var $confPHPTpl = '<?php
$CONF[\'giftIds\'] = ';
	
	public function createGmAward() {	

		$res = $this->setConf();
		
		return $res;
	}
	
	// 处理
	public function setConf() {
		$replace = array();
		$replace[] = '{name}';
		$replace[] = '{confId}';
		
		$file 	= ROOT_PATH . $this->OBJ->excelDir . $this->fileName;
		// ios 
		$gifts 	= MooObj::get('Control_ExcelConfMaker_Excel')->read($file, 'UTF-8', 0);		
		
		$giftCons = array();
		if($gifts) {
			foreach ($gifts as $key => $val) {
				$giftCon['name'] = $val['name'];
				$giftCon['type'] = $val['type'];
				$giftCon['itemId'] = $val['itemId'];
				$giftCons[] = $giftCon;
			}
		}
		
		MooArray::tdSort($giftCons, 'type',SORT_ASC , 'itemId', SORT_ASC);
						
		$confTpl = $this->confPHPTpl . format_array_to_string_byStarten($giftCons);		
		
		$result = MooFile::write(ROOT_PATH . '/conf/gm_awardsinfo.conf.php', $confTpl);
// 		MooView::set('confTpl', highlight_string($confTpl, true));
		return highlight_string($confTpl, true);
	}
}